Skip to content

feat: add semanticOverride support for SEMANTIC memory strategies#696

Merged
aidandaly24 merged 1 commit intoaws:mainfrom
aidandaly24:feat/semantic-override-678
Mar 27, 2026
Merged

feat: add semanticOverride support for SEMANTIC memory strategies#696
aidandaly24 merged 1 commit intoaws:mainfrom
aidandaly24:feat/semantic-override-678

Conversation

@aidandaly24
Copy link
Copy Markdown
Contributor

@aidandaly24 aidandaly24 commented Mar 27, 2026

Description

Add semanticOverride support for SEMANTIC memory strategies, allowing users to customize extraction and consolidation behavior with custom prompts and model IDs.

Changes

  • Schema: Add SemanticExtractionOverrideSchema, SemanticConsolidationOverrideSchema, and SemanticOverrideSchema with Zod validation
  • Cross-field validation: .refine() rejects semanticOverride on non-SEMANTIC strategy types with a clear error message
  • Barrel exports: Update primitives/index.ts, agentcore-project.ts for new schema/type exports
  • LLM-compacted: Update agentcore.ts interface with semanticOverride field

Schema Structure

{
  "strategies": [{
    "type": "SEMANTIC",
    "namespaces": ["/users/{actorId}/facts"],
    "semanticOverride": {
      "extraction": {
        "appendToPrompt": "Extract key facts about the user",
        "modelId": "anthropic.claude-3-sonnet-20240229-v1:0"
      },
      "consolidation": {
        "appendToPrompt": "Consolidate user memories",
        "modelId": "anthropic.claude-3-haiku-20240307-v1:0"
      }
    }
  }]
}

TUI Screenshots

Validation — pass and fail:
validate-pass-and-fail

agentcore.json with semanticOverride config:
agentcore-json-override-config

Synthesized CloudFormation template with SemanticOverride:
cfn-template-semantic-override

All memory unit tests passing (vitest):
unit-tests-memory-pass

Service-Side Note

The CloudFormation resource AWS::BedrockAgentCore::Memory in us-east-1 does not yet include SemanticOverride in its schema. The CLI schema validation and CDK template generation are correct — deployments with overrides will succeed once the service-side schema is updated. Backward compatibility (SEMANTIC without override) is confirmed working.

Related Issue

Closes #678

Documentation PR

N/A — pending service-side schema availability

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Test Coverage

  • 13 new schema unit tests covering:
    • Valid extraction-only, consolidation-only, and both overrides
    • Rejection of semanticOverride on SUMMARIZATION, USER_PREFERENCE, CUSTOM strategies
    • Rejection of empty override (neither extraction nor consolidation)
    • appendToPrompt boundary validation (empty, max 30000)
    • modelId minimum length validation
    • Consolidation-only rejection on USER_PREFERENCE
  • 2 integration tests in agentcore-project.test.ts for full project spec with overrides
  • E2E deployment testing across 4 scenarios (validate, synth, deploy, invoke)

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Dependent CDK PR: aws/agentcore-l3-cdk-constructs#120 (companion PR with addPropertyOverride implementation)


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aidandaly24 aidandaly24 requested a review from a team March 27, 2026 04:32
@github-actions github-actions bot added the size/m PR size: M label Mar 27, 2026
@aidandaly24
Copy link
Copy Markdown
Contributor Author

TUI Screenshots

Screenshots captured during E2E testing of the SemanticOverride feature:

  1. Validation (pass + fail): validate-pass-and-fail.svg

    • agentcore validate passes for valid override configs
    • agentcore validate fails with clear error for semanticOverride on SUMMARIZATION
  2. Override JSON config: agentcore-json-override-config.svg

    • Shows semanticOverride with extraction + consolidation in agentcore.json
  3. CloudFormation template: cfn-template-semantic-override.svg

    • Synthesized template with SemanticOverride.Extraction and SemanticOverride.Consolidation
  4. Unit tests: unit-tests-memory-pass.svg

    • All 28 memory schema tests passing (vitest)

View all screenshots in the gist

@aidandaly24 aidandaly24 force-pushed the feat/semantic-override-678 branch from a42ba14 to e692ae4 Compare March 27, 2026 04:47
@github-actions github-actions bot added size/m PR size: M and removed size/m PR size: M labels Mar 27, 2026
…s#678)

Add SemanticOverride schema support to memory strategies, allowing users
to customize extraction and consolidation behavior with custom prompts
and model IDs on SEMANTIC strategy types.

Changes:
- Add SemanticExtractionOverrideSchema, SemanticConsolidationOverrideSchema,
  and SemanticOverrideSchema with at-least-one validation
- Add cross-field validation rejecting semanticOverride on non-SEMANTIC types
- Export new schemas and types through barrel files
- Update LLM-compacted types with semanticOverride interface
- Add 13 new unit tests for override validation
- Add 2 integration tests for agentcore-project validation

Constraint: semanticOverride only valid on SEMANTIC strategy type
Constraint: At least one of extraction or consolidation must be provided
Rejected: Allow override on all strategy types | CFn only supports it on SEMANTIC
Confidence: high
Scope-risk: narrow
@aidandaly24 aidandaly24 force-pushed the feat/semantic-override-678 branch from e692ae4 to 911f3e9 Compare March 27, 2026 05:20
@github-actions github-actions bot removed the size/m PR size: M label Mar 27, 2026
@github-actions github-actions bot added the size/m PR size: M label Mar 27, 2026
@aidandaly24 aidandaly24 merged commit 5e0f584 into aws:main Mar 27, 2026
16 of 19 checks passed
aidandaly24 added a commit that referenced this pull request Mar 27, 2026
aidandaly24 added a commit that referenced this pull request Mar 27, 2026
aidandaly24 added a commit that referenced this pull request Mar 27, 2026
* Revert "feat: add semanticOverride support for SEMANTIC memory strategies (#678) (#696)"

This reverts commit 5e0f584.

* Revert "feat(memory): add CUSTOM strategy type to agentcore-cli (#677) (#694)"

This reverts commit beac707.

* fix: restore EPISODIC strategy to configuration.md

The revert of the CUSTOM strategy commit inadvertently removed the
EPISODIC row from the Memory Strategies table in configuration.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Built-in strategy with override not yet supported in AgentCore memory

2 participants